<!DOCTYPE HTML>
<!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
  <meta charset="utf-8">
  <title>Reference: subgrid inside a parent with repeat(auto-fit) rows</title>
  <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
  <style>
html,body {
  color:black; background-color:white; font:10px/1 monospace; padding:0; margin:0;
}

.grid {
  display: inline-grid;
  height: 50px;
  width: 50px;
  grid-template-columns: repeat(auto-fit, 10px);
  border: 1px solid;
  vertical-align: top;
}

.subgrid {
  display: grid;
  grid: subgrid / subgrid;
  grid-column: 1 / -1;
  grid-row: 3 / span 4;
  grid-auto-columns: 8px;
  background: grey;
}

.fit-0a  { grid-template-rows: [y] 0px [z] 1px [z] 1px [z] 1px [z] 1px [z]; }
.fit-0b  { grid-template-rows: [x y] 0px [z] 1px [z] 1px [z] 1px [z]; }
.fit-0c  { grid-template-rows: [x] 1px [x y] 0px [y] 10px [y] 10px [y] 10px [z] 1px [z] 1px [z]; }
.fit-0d  { grid-template-rows: [x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 10px [z] 1px [z]; }
.fit-0e  { grid-template-rows: [x] 2px [x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 0px [z]; }
.fit-0f  { grid-template-rows: [x] 2px [x] 2px [x] 2px [x] 2px [x y] 10px [y] 10px [y] 0px [y] 0px; }
.fit-0g  { grid-template-rows: [x] 2px [x] 2px [x] 2px [x] 2px [x y] 10px [y] 10px [y] 0px [y] 0px [z] 1px [z]; }
.fit-0h  { grid-template-rows: [x] 2px [x] 2px [x] 2px [x] 2px [x] 2px [x] 2px [x y] 0px [y] 0px [y] 0px [z] 1px [z]; }
.fit-0i  { grid-template-rows: [x] 2px [x] 2px [x] 2px [x] 2px [x] 2px [x] 2px [x y] 0px [y] 0px [y] 0px [z]; }
.fit-0j  { grid-template-rows: [x] 2px [x] 2px [x] 2px [x] 2px [x] 2px [x] 2px [x y] 0px [y] 0px [y] 0px; }
.fit-0k  { grid-template-rows: [y] 0px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px; }
.fit-0l  { grid-template-rows: [x y] 0px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px [z] 10px; }
.fit-0m  { grid-template-rows: [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [x] 10px [y] 0px; }

.fit-1a  { grid-template-rows: [y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 1px [z] 1px [z]; }
.fit-1b  { grid-template-rows: [x y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 1px [z]; }
.fit-1c  { grid-template-rows: [x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px [z] 1px [z]; }
.fit-1d  { grid-template-rows: [x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 10px [z]; }
.fit-1e  { grid-template-rows: [x] 2px [x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 0px; }

.fit-2a  { grid-template-rows: [y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z] 1px [z]; }
.fit-2b  { grid-template-rows: [x y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z]; }
.fit-2c  { grid-template-rows: [x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px [z]; }
.fit-2d  { grid-template-rows: [x] 2px [x] 2px [x y] 10px [y] 10px [y] 10px [y] 10px; }

.fit-3a  { grid-template-rows: [y] 0px [y] 0px [y] 10px [y] 10px [z] 1px [z]; }
.fit-3b  { grid-template-rows: [x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z]; }
.fit-3c  { grid-template-rows: [x] 2px [x y] 0px [y] 10px [y] 10px [y] 10px; }

.fit-4a  { grid-template-rows: [y] 0px [y] 0px [y] 10px [y] 10px [y] 10px [z]; }
.fit-4b  { grid-template-rows: [x y] 0px [y] 0px [y] 10px [y] 10px [y] 10px; }

.fit-5   { grid-template-rows: [y] 0px [y] 0px [y] 10px [y] 10px [y] 10px; }

.subgrid > :nth-child(2n)   {  background: black; }
.subgrid > :nth-child(2n+1) {  background: pink; }

  </style>
</head>
<body>

<div class="grid fit-0a"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0b"><div class="subgrid" style="grid-column-start:2">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0c"><div class="subgrid" style="grid-column-start:3">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0d"><div class="subgrid" style="grid-column-start:4">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0e"><div class="subgrid" style="grid-column-start:5">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0f"><div class="subgrid" style="grid-column-start:6">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0g"><div class="subgrid" style="grid-column-end:-2">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0h"><div class="subgrid" style="grid-column-end:-3">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0i"><div class="subgrid" style="grid-column-end:-4">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0j"><div class="subgrid" style="grid-column-end:-5">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0k"><div class="subgrid" style="grid-column-end:-6">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0l"><div class="subgrid" style="grid-column:2/-2">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-0m"><div class="subgrid" style="grid-column:3/-3">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-1a"><div class="subgrid" style="grid-column:2/-3">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-1b"><div class="subgrid" style="grid-column:3/-2">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-1c"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-1d"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-1e"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-2a"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-2b"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-2c"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-2d"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-3a"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-3b"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-3c"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-4a"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-4b"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>

<div class="grid fit-5"><div class="subgrid">
  <div style="grid-row:y 5"></div>
  <div style="grid-row:y 4"></div>
  <div style="grid-row:y 3"></div>
  <div style="grid-row:y 2"></div>
  <div style="grid-row:y 1"></div>
  <div style="grid-row:y -1"></div>
  <div style="grid-row:y -2"></div>
  <div style="grid-row:y -3"></div>
  <div style="grid-row:y -4"></div>
  <div style="grid-row:y -5"></div>
</div></div>


</body>
</html>
